<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h2>事件处理</h2>
      <p>count: {{count}}</p>
      <!-- <button v-on:click="count++">btn</button> -->
      <button @click="handleClick(2, $event)">btn count+2</button>
      <button @click="handleClick(3, $event)">btn count+3</button>
    </div>

    <script src="./lib/vue3.js"></script>
    <script>
      Vue.createApp({
        data() {
          return {
            count: 1,
          };
        },
        methods: {
          // 每一个事件处理函数，都可以直接获取到event参数(事件对象),不能加括号
          // handleClick(event) {
          //   console.log(event);
          //   this.count++;
          // },

          // 加了括号就可以传参了
          // 加了括号还想拿到事件对象，需要手动传入$event
          handleClick(num, e) {
            console.log(num, e);
            this.count += num;
          },
        },
      }).mount("#app");
    </script>
  </body>
</html>
